package cn.edu.scau.cmi.zhengweibo.composite.consistent;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import cn.edu.scau.cmi.zhengweibo.composite.safe.SafeComponent;

public abstract class ConsistentComponent {
	public String name;
	public ConsistentComponent(String name) {
		this.name = name;
	}
	public  List<ConsistentComponent> child = new ArrayList<>();
	
	
	public abstract String getName();

	public abstract void show(String str);
	
	public abstract String show1(String str);
	
	public abstract void add(ConsistentComponent component);
	
	public abstract  void remove(ConsistentComponent component);
	
	public ConsistentComponent find(String name) {
		for(ConsistentComponent s : child) {
			if(s.getName().equals(name)){
				return s;
			}else if(s.child!=null) {
				for(ConsistentComponent c : s.child) {
					c.find(name);
				}
			}
		}
		return null;
	}
}
